//
//  CommonFunction.m
//  SaySomething
//
//  Created by Edward Zhang on 12-4-3.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "JddCommonFunction.h"
#import <sys/socket.h>
#import <sys/sysctl.h>
#import <net/if.h>
#import <net/if_dl.h>
#import "JddGlobal.h"
//#import "JddHomeViewController.h"
#import <CommonCrypto/CommonDigest.h>
#import "OHASBasicHTMLParser.h"

@implementation JddCommonFunction

+ (double)factorialNumber:(NSInteger)number{
    double result = 1;
    for (int i = 2; i < number + 1; ++i) {
        result *= i;
    }
    return result;
}

+ (NSInteger)recurseBallNumber:(NSInteger)ballAmount combinationNumber:(NSInteger)combinationNumber{
    return [JddCommonFunction factorialNumber:ballAmount] / ([JddCommonFunction factorialNumber:ballAmount - combinationNumber] * [JddCommonFunction factorialNumber:combinationNumber]);
}

+ (NSInteger)countShuangSeQiuTotalNumber:(NSInteger)redBallAmount blueBallAmount:(NSInteger)blueBallAmount{
    if (redBallAmount>5&&blueBallAmount>0) {
        NSInteger redBallCombination = [JddCommonFunction recurseBallNumber:redBallAmount combinationNumber:6];
        NSInteger blueBallCombination = blueBallAmount;
        return redBallCombination * blueBallCombination;
    }else {
        return 0;
    }
    
}

+(void)generateball:(JddShuangSeQiuNumber *)number max:(NSInteger)max count:(NSInteger)count{
    [number clearRedBallNumber];
    for (int i=0; i<count; i++) {
        BOOL redo = NO;
        NSInteger randomNumber = 0;
        do {
            redo = NO;
            randomNumber = arc4random()%max + 1;
            if ([number redBallHasNumber:randomNumber]) {
                redo = YES;
            }
        } while (redo);
        [number addRedBallNumber:randomNumber];
    }
}

+ (void)generateRedBallOfShuangSeQiuNumber:(JddShuangSeQiuNumber*)ssqNumber count:(NSInteger)count{
    while (count < 6 || count > 20) {
        count = arc4random() % 21;
    }
    
    [ssqNumber clearRedBallNumber];
    
    for (int i = 0; i < count; ++i) {
        BOOL redo = NO;
        
        NSInteger randomNumber = 0;
        do {
            redo = NO;
            
            randomNumber = arc4random() % 34;
            if (randomNumber == 0) {
                redo = YES;
                continue;
            }
            
            if ([ssqNumber redBallHasNumber:randomNumber]) {
                redo = YES;
            }
        } while (redo);
        
        [ssqNumber addRedBallNumber:randomNumber];
    }    
}

+ (void)generateBlueBallOfShuangSeQiuNumber:(JddShuangSeQiuNumber*)ssqNumber count:(NSInteger)count{
    while (count < 1 || count > 16) {
        count = arc4random() % 17;
    }
    
    [ssqNumber clearBlueBallNumber];
    
    for (int i = 0; i < count; ++i) {
        BOOL redo = NO;
        
        NSInteger randomNumber = 0;
        do {
            redo = NO;
            
            randomNumber = arc4random() % 17;
            if (randomNumber == 0) {
                redo = YES;
                continue;
            }
            
            if ([ssqNumber blueBallHasNumber:randomNumber]) {
                redo = YES;
            }
        } while (redo);
        
        [ssqNumber addBlueBallNumber:randomNumber];
    }
}

+ (NSInteger)countDaLeTouTotalNumber:(NSInteger)headBallAmount backBallAmount:(NSInteger)backBallAmount{
    if (headBallAmount>4&&backBallAmount>1) {
        NSInteger headBallCombination = [JddCommonFunction recurseBallNumber:headBallAmount combinationNumber:5];
        NSInteger backBallCombination = [JddCommonFunction recurseBallNumber:backBallAmount combinationNumber:2];
        return headBallCombination * backBallCombination;
    }else {
        return 0;
    }
}

+(NSInteger)countSport:(NSInteger)number1 number:(NSInteger) number2{
    NSInteger result;
    result = [JddCommonFunction recurseBallNumber:number1 combinationNumber:number2];
    return result;
}

+(NSInteger)countS5TotalNumber:(NSInteger)BallAmount playmethod:(NSInteger)playmethod{
    NSInteger BallCombination;
    if (playmethod==7009) {
    BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:2]*2;
    } else if (playmethod==7010) {
        BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:3]*2*3;
    } else if (playmethod==7011) {
        BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:2];
    } else if (playmethod==7012) {
        BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:3];
    } else if (playmethod < 7009) {
    BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:(playmethod-7000)];
    } else {
        NSLog(@"haha");
    }
    return BallCombination;    
}

+(NSInteger)count11YDJTotalNumber:(NSInteger)BallAmount playmethod:(NSInteger)playmethod{
    NSInteger BallCombination;
    if (playmethod==LOTTERY_PLAY_METHOD_11YDJ_ONLY2) {
        BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:2]*2;
    } else if (playmethod==LOTTERY_PLAY_METHOD_11YDJ_ONLY3) {
        BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:3]*2*3;
    } else if (playmethod==LOTTERY_PLAY_METHOD_11YDJ_GROUP2) {
        BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:2];
    } else if (playmethod==LOTTERY_PLAY_METHOD_11YDJ_GROUP3) {
        BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:3];
    } else if (playmethod < LOTTERY_PLAY_METHOD_11YDJ_ONLY2){
        BallCombination = [JddCommonFunction recurseBallNumber:BallAmount combinationNumber:(playmethod-LOTTERY_PLAY_METHOD_11YDJ_ANY0)];
    }
    return BallCombination;
}

+(NSArray*)sortArray:(NSArray *)array{
    NSArray *sortedArray = [array sortedArrayUsingComparator: ^(id obj1, id obj2) {
        
        if ([obj1 integerValue] > [obj2 integerValue]) {
            return (NSComparisonResult)NSOrderedDescending;//递减
        }
        
        if ([obj1 integerValue] < [obj2 integerValue]) {
            return (NSComparisonResult)NSOrderedAscending;//上升
        }
        return (NSComparisonResult)NSOrderedSame;
    }];
    return sortedArray;
}

+ (void)generateheadBallOfDaLeTouNumber:(JddDaletouNumber*)dltNumber count:(NSInteger)count{
    while (count < 5 || count > 18) {
        count = arc4random() % 19;
    }
    
    [dltNumber clearheadBallNumber];
    
    for (int i = 0; i < count; ++i) {
        BOOL redo = NO;
        
        NSInteger randomNumber = 0;
        do {
            redo = NO;
            
            randomNumber = arc4random() % 36;
            if (randomNumber == 0) {
                redo = YES;
                continue;
            }
            
            if ([dltNumber headBallHasNumber:randomNumber]) {
                redo = YES;
            }
        } while (redo);
        
        [dltNumber addheadBallNumber:randomNumber];
    }    
}

+ (void)generatebackBallOfDaLeTouNumber:(JddDaletouNumber*)dltNumber count:(NSInteger)count{
    while (count < 2 || count > 12) {
        count = arc4random() % 13;
    }
    
    [dltNumber clearbackBallNumber];
    
    for (int i = 0; i < count; ++i) {
        BOOL redo = NO;
        
        NSInteger randomNumber = 0;
        do {
            redo = NO;
            
            randomNumber = arc4random() % 13;
            if (randomNumber == 0) {
                redo = YES;
                continue;
            }
            
            if ([dltNumber backBallHasNumber:randomNumber]) {
                redo = YES;
            }
        } while (redo);
        
        [dltNumber addbackBallNumber:randomNumber];
    }
}

+ (void)generateBallOf11s5Number:(JddS5F11Number*)s5Number type:(NSInteger)type{
    
    [s5Number clear];
    if (type>7000&&type<7009) {
        for (int i = 0; i < (type-7000); ++i) {
            BOOL redo = NO;
            
            NSInteger randomNumber = 0;
            do {
                redo = NO;
                
                randomNumber = arc4random() % 12;
                if (randomNumber == 0) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number BallHasNumber:randomNumber]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number addBallNumber:randomNumber];
            
        }
    } else if (type==7009) {
            BOOL redo = NO;
            
            NSInteger randomNumber = 0;
            do {
                redo = NO;
                
                randomNumber = arc4random() % 12;
                if (randomNumber == 0) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number BallHasNumber:randomNumber]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number addBallNumber:randomNumber];
        NSInteger randomNum2 = 0;
        do {
            redo = NO;
            
            randomNum2 = arc4random() % 12;
            if (randomNum2 == 0||randomNum2 == randomNumber) {
                redo = YES;
                continue;
            }
            
            if ([s5Number Ball2HasNumber:randomNum2]) {
                redo = YES;
            }
        } while (redo);
        
        [s5Number add2BallNumber:randomNum2];
            
        
    }else if (type==7010) {
            BOOL redo = NO;
            
            NSInteger randomNumber = 0;
            do {
                redo = NO;
                
                randomNumber = arc4random() % 12;
                if (randomNumber == 0) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number BallHasNumber:randomNumber]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number addBallNumber:randomNumber];
            NSInteger randomNum2 = 0;
            do {
                redo = NO;
                
                randomNum2 = arc4random() % 12;
                if (randomNum2 == 0||randomNum2 == randomNumber) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number Ball2HasNumber:randomNum2]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number add2BallNumber:randomNum2];
            NSInteger randomNum3 = 0;
            do {
                redo = NO;
                
                randomNum3 = arc4random() % 12;
                if (randomNum3 == 0||randomNum3 == randomNum2 ||randomNum3 == randomNumber) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number Ball3HasNumber:randomNum3]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number add3BallNumber:randomNum3];
            
        
    } else if (type==7011) {
        for (int i = 0; i < 2; ++i) {
            BOOL redo = NO;
            
            NSInteger randomNumber = 0;
            do {
                redo = NO;
                
                randomNumber = arc4random() % 12;
                if (randomNumber == 0) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number BallHasNumber:randomNumber]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number addBallNumber:randomNumber];
            
        }
    }else if (type==7012) {
        for (int i = 0; i < 3; ++i) {
            BOOL redo = NO;
            
            NSInteger randomNumber = 0;
            do {
                redo = NO;
                
                randomNumber = arc4random() % 12;
                if (randomNumber == 0) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number BallHasNumber:randomNumber]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number addBallNumber:randomNumber];
            
        }
    }

}

+ (void)generateBallOf11YDJNumber:(JddS5F11Number*)s5Number type:(NSInteger)type{
    
    [s5Number clear];
    if (type>LOTTERY_PLAY_METHOD_11YDJ_ANY0&&type<LOTTERY_PLAY_METHOD_11YDJ_ONLY2) {
        for (int i = 0; i < (type-LOTTERY_PLAY_METHOD_11YDJ_ANY0); ++i) {
            BOOL redo = NO;
            
            NSInteger randomNumber = 0;
            do {
                redo = NO;
                
                randomNumber = arc4random() % 12;
                if (randomNumber == 0) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number BallHasNumber:randomNumber]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number addBallNumber:randomNumber];
            
        }
    } else if (type==LOTTERY_PLAY_METHOD_11YDJ_ONLY2) {
        BOOL redo = NO;
        
        NSInteger randomNumber = 0;
        do {
            redo = NO;
            
            randomNumber = arc4random() % 12;
            if (randomNumber == 0) {
                redo = YES;
                continue;
            }
            
            if ([s5Number BallHasNumber:randomNumber]) {
                redo = YES;
            }
        } while (redo);
        
        [s5Number addBallNumber:randomNumber];
        NSInteger randomNum2 = 0;
        do {
            redo = NO;
            
            randomNum2 = arc4random() % 12;
            if (randomNum2 == 0||randomNum2 == randomNumber) {
                redo = YES;
                continue;
            }
            
            if ([s5Number Ball2HasNumber:randomNum2]) {
                redo = YES;
            }
        } while (redo);
        
        [s5Number add2BallNumber:randomNum2];
        
        
    }else if (type==LOTTERY_PLAY_METHOD_11YDJ_ONLY3) {
        BOOL redo = NO;
        
        NSInteger randomNumber = 0;
        do {
            redo = NO;
            
            randomNumber = arc4random() % 12;
            if (randomNumber == 0) {
                redo = YES;
                continue;
            }
            
            if ([s5Number BallHasNumber:randomNumber]) {
                redo = YES;
            }
        } while (redo);
        
        [s5Number addBallNumber:randomNumber];
        NSInteger randomNum2 = 0;
        do {
            redo = NO;
            
            randomNum2 = arc4random() % 12;
            if (randomNum2 == 0||randomNum2 == randomNumber) {
                redo = YES;
                continue;
            }
            
            if ([s5Number Ball2HasNumber:randomNum2]) {
                redo = YES;
            }
        } while (redo);
        
        [s5Number add2BallNumber:randomNum2];
        NSInteger randomNum3 = 0;
        do {
            redo = NO;
            
            randomNum3 = arc4random() % 12;
            if (randomNum3 == 0||randomNum3 == randomNum2 ||randomNum3 == randomNumber) {
                redo = YES;
                continue;
            }
            
            if ([s5Number Ball3HasNumber:randomNum3]) {
                redo = YES;
            }
        } while (redo);
        
        [s5Number add3BallNumber:randomNum3];
        
        
    } else if (type==LOTTERY_PLAY_METHOD_11YDJ_GROUP2) {
        for (int i = 0; i < 2; ++i) {
            BOOL redo = NO;
            
            NSInteger randomNumber = 0;
            do {
                redo = NO;
                
                randomNumber = arc4random() % 12;
                if (randomNumber == 0) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number BallHasNumber:randomNumber]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number addBallNumber:randomNumber];
            
        }
    }else if (type==LOTTERY_PLAY_METHOD_11YDJ_GROUP3) {
        for (int i = 0; i < 3; ++i) {
            BOOL redo = NO;
            
            NSInteger randomNumber = 0;
            do {
                redo = NO;
                
                randomNumber = arc4random() % 12;
                if (randomNumber == 0) {
                    redo = YES;
                    continue;
                }
                
                if ([s5Number BallHasNumber:randomNumber]) {
                    redo = YES;
                }
            } while (redo);
            
            [s5Number addBallNumber:randomNumber];
            
        }
    }
    
}


+(NSDate*)dateFromString:(NSString*)dateString{
    NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
    
    NSArray *dateTimeArray = [dateString componentsSeparatedByString:@" "];
    if ([dateTimeArray count] == 2) {
        NSArray *dateArray = [[dateTimeArray objectAtIndex:0] componentsSeparatedByString:@"-"];
        if ([dateArray count] == 3) {
            [dateComponents setYear:[[dateArray objectAtIndex:0] intValue]];
            [dateComponents setMonth:[[dateArray objectAtIndex:1] intValue]];
            [dateComponents setDay:[[dateArray objectAtIndex:2] intValue]];
        }
        NSArray *timeArray = [[dateTimeArray objectAtIndex:1] componentsSeparatedByString:@":"];
        if ([timeArray count] == 3) {
            [dateComponents setHour:[[timeArray objectAtIndex:0] intValue]];
            [dateComponents setMinute:[[timeArray objectAtIndex:1] intValue]];
            [dateComponents setSecond:[[timeArray objectAtIndex:2] intValue]];
        }
    }
    
    NSCalendar *calendar = [NSCalendar currentCalendar];
    return [calendar dateFromComponents:dateComponents];
}

+(NSString *)getDateTimeWithEndTime:(NSString *)endTime
{
    return [endTime substringToIndex:endTime.length - 3];
}


+(void)setWaitingViewHidden:(BOOL)hidden fromController:(UIViewController*)parentController{
    JddGlobal *jddGlobal = [JddGlobal sharedInstance];
    if (hidden) {
        [MBProgressHUD hideAllHUDsForView:parentController.view animated:YES];
        [parentController.view setUserInteractionEnabled:YES];
        [jddGlobal.navigationController.navigationBar setUserInteractionEnabled:YES];
    } else {
        [MBProgressHUD showHUDAddedTo:parentController.view animated:YES];
        [parentController.view setUserInteractionEnabled:NO];
        [jddGlobal.navigationController.navigationBar setUserInteractionEnabled:NO];
    }
}

+(void)setViewHidden:(BOOL)hidden fromController:(UIViewController*)parentController{
    JddGlobal *jddGlobal = [JddGlobal sharedInstance];
    [jddGlobal.navigationController.navigationBar setUserInteractionEnabled:hidden];
}

+(NSString*)thisDocumentPath{
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
}

+(NSString*)binaryFilePath{
    NSString *binaryFilePath = [NSString stringWithFormat:@"%@/binary", [JddCommonFunction thisDocumentPath]];
    if (![[NSFileManager defaultManager] fileExistsAtPath:binaryFilePath]) {
        [[NSFileManager defaultManager] createDirectoryAtPath:binaryFilePath 
                                  withIntermediateDirectories:YES 
                                                   attributes:nil 
                                                        error:nil];
    }
    return binaryFilePath;
}

+(id)createObjectFromNibName:(NSString*)nibName{
    return [[[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil] objectAtIndex:0];
}

+(void)messageBoxWithMessage:(NSString*)message{
    static UIAlertView *alert = nil;
    alert.message = message;
    if (!alert) {

        alert = [[UIAlertView alloc] initWithTitle:APP_NAME 
                                                        message:message 
                                                       delegate:nil 
                                              cancelButtonTitle:OK 
                                              otherButtonTitles:nil, nil];

    }
    else {

            alert = [[UIAlertView alloc] initWithTitle:APP_NAME 
                                               message:message 
                                              delegate:nil 
                                     cancelButtonTitle:@"确定" 
                                     otherButtonTitles:nil, nil];	
    }

    if (![alert isVisible]) {
        [alert show];
    }
}

+(NSString*)dateTimeStringNoSeperator{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSInteger  flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
    
    NSDateComponents *dateComponents = [calendar components:flags fromDate:[NSDate date]];
    
    return [NSString stringWithFormat:@"%d%02d%02d%02d%02d%02d", dateComponents.year, dateComponents.month, dateComponents.day, dateComponents.hour, dateComponents.minute, dateComponents.second];
}

+(NSString*)dateTimeStringNormal{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSInteger  flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
    
    NSDateComponents *dateComponents = [calendar components:flags fromDate:[NSDate date]];
    
    return [NSString stringWithFormat:@"%d-%02d-%02d %02d%02d%02d", dateComponents.year, dateComponents.month, dateComponents.day, dateComponents.hour, dateComponents.minute, dateComponents.second];
}

+(NSString*)dateTimeStringNormalFromDate:(NSDate*)date{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSInteger  flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
    
    NSDateComponents *dateComponents = [calendar components:flags fromDate:date];
    
    return [NSString stringWithFormat:@"%d-%02d-%02d %02d:%02d:%02d", dateComponents.year, dateComponents.month, dateComponents.day, dateComponents.hour, dateComponents.minute, dateComponents.second];
}

+(BOOL)checkNetWork{
    BOOL isExistenceNetWork;
    Reachability *reachability = [Reachability reachabilityWithHostName:@"www.jiangduoduo.com"];
    switch ([reachability currentReachabilityStatus]) {
        case NotReachable://无网络
            isExistenceNetWork = FALSE;
            break;
        case ReachableViaWWAN://使用3G或RPRS
            isExistenceNetWork = TRUE;
            break;
        case ReachableViaWiFi://使用WiFi
            isExistenceNetWork = TRUE;
            break;
    }
    return isExistenceNetWork;
}

+(NSString*)macAddress{
	int                    mib[6];
	size_t                len;
	char                *buf;
	unsigned char        *ptr;
	struct if_msghdr    *ifm;
	struct sockaddr_dl    *sdl;
	
	mib[0] = CTL_NET;
	mib[1] = AF_ROUTE;
	mib[2] = 0;
	mib[3] = AF_LINK;
	mib[4] = NET_RT_IFLIST;
	
	if ((mib[5] = if_nametoindex("en0")) == 0) {
		NSLog(@"Error: if_nametoindex error/n");
		return nil;
	}
	
	if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
		NSLog(@"Error: sysctl, take 1/n");
		return nil;
	}
	
	if ((buf = malloc(len)) == NULL) {
		NSLog(@"Could not allocate memory. error!/n");
		return nil;
	}
	
	if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
		NSLog(@"Error: sysctl, take 2");
		return nil;
	}
	
	ifm = (struct if_msghdr *)buf;
	sdl = (struct sockaddr_dl *)(ifm + 1);
	ptr = (unsigned char *)LLADDR(sdl);
	NSString *outstring = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x", *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)];
	free(buf);
	return [outstring uppercaseString];
}

+(UIImage*)scaleToSizeOfImage:(UIImage*)image size:(CGSize)size  
{  
    UIGraphicsBeginImageContext(size);  

    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];  
    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();  
    UIGraphicsEndImageContext();  
    return scaledImage;  
}

+(NSString*)dateTimeStringFromTickcount:(double)tickcount{
    NSCalendar *calender = [NSCalendar currentCalendar];
    NSInteger  flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
    
    NSDateComponents *dateComp = [calender components:flags fromDate:[NSDate dateWithTimeIntervalSince1970:tickcount]];
    return [NSString stringWithFormat:@"%d-%02d-%02d %02d:%02d:%02d", 
            dateComp.year, 
            dateComp.month, 
            dateComp.day, 
            dateComp.hour, 
            dateComp.minute, 
            dateComp.second];
}

+(void)pushViewController:(UIViewController*)controller navigationController:(UINavigationController*)navigationController{
    if ([[navigationController viewControllers] containsObject:controller]) {
        [navigationController popToViewController:controller animated:YES];
    }
    else {
        [navigationController pushViewController:controller animated:YES];
    }
}

+(UIFont*)jddFont{
    return [UIFont systemFontOfSize:15.0];
}

+ (BOOL)isLogin
{
    if ([JddUserProfile sharedInstance].password.length >5 || [JddUserProfile sharedInstance].userId.length > 0) {
        return YES;
    }
    return NO;
}

+ (NSString *)convertWeekByNumber:(NSString *)number
{
    switch ([number intValue]) {
        case 1:
            return @"周一";
            break;
        case 2:
            return @"周二";
            break;
        case 3:
            return @"周三";
            break;
        case 4:
            return @"周四";
            break;
        case 5:
            return @"周五";
            break;
        case 6:
            return @"周六";
            break;
        case 7:
            return @"周日";
            break;
        default:
            return @"-";
            break;
    }
}

+(NSString *)getOpenEndDateWithEndtime:(NSString *)endTime
{
    NSDate *date = [self NSStringToNSDate:endTime];
    NSCalendar *gregorian = [[NSCalendar alloc]
                             initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents* dc1 = [[NSDateComponents alloc] init];
    [dc1 setDay:60];
    NSDate *tmpDate = [gregorian dateByAddingComponents:dc1 toDate:date options:0];
    NSString *dateStr = [self NSDateToNSString:tmpDate];
    return dateStr;
}

+ (NSDate *)NSStringToNSDate:(NSString *)string
{
    NSTimeZone *zone = [NSTimeZone systemTimeZone];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:kDEFAULT_DATE_TIME_FORMAT];
    NSDate *sDate=[dateFormatter dateFromString:string];
    NSInteger intervalSDate = [zone secondsFromGMTForDate: sDate];
    sDate = [sDate dateByAddingTimeInterval: intervalSDate];
    return sDate;
}

+ (NSString *)NSDateToNSString:(NSDate *)date
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:kDEFAULT_DATE_FORMAT];
    NSTimeZone* GTMzone = [NSTimeZone timeZoneForSecondsFromGMT:0];
    [dateFormatter setTimeZone:GTMzone];

    NSString *currentDateStr = [dateFormatter stringFromDate:date];
    return currentDateStr;
}

+ (NSString *)getStringDateWithStringDateTime:(NSString *)dateTimeStr
{
    return [self NSDateToNSString:[self NSStringToNSDate:dateTimeStr]];
}

+(void)paramsWithQXCorPWArray:(NSArray *)ballArrays AndString:(NSMutableString *)lotString
{
    for(NSArray *ballArray in ballArrays){
        NSArray * ball = [JddCommonFunction sortArray: ballArray];
        if ([ball count] > 1) {
            [lotString appendString:@"("];
            for (NSNumber *number in ball) {
                [lotString appendFormat:@"%d", [number intValue]];
            }
            [lotString appendString:@")"];
        }else{
            [lotString appendFormat:@"%d", [[ball objectAtIndex:0] intValue]];
        }
    }
}

+(NSAttributedString *)convertHTMLFontRedWithResult :(NSString *)result AndCellLabel :(UILabel *)label
{
    result = [result stringByReplacingOccurrencesOfString:@"<br/>" withString:@""];
    result = [result stringByReplacingOccurrencesOfString:@"#a50000" withString:@"\"#a50000\""];
    result = [result stringByReplacingOccurrencesOfString:@"class" withString:@"color"];
    result = [result stringByReplacingOccurrencesOfString:@"=red>" withString:@"='red'>"];
    label.text = result;
    NSMutableAttributedString *string ;
    if (result.length > 0) {
        string = [OHASBasicHTMLParser attributedStringByProcessingMarkupInAttributedString:label.attributedText];
    }
    return string;
}

+(NSString *)getCGByKey:(NSString *)cg
{
    NSString *cgResult = @"-";
    if(![cg isEqualToString:@""]){
        NSArray *cgArray = [cg componentsSeparatedByString:@":"];
        if (cgArray.count > 1) {
            NSString *cgTemp = [cgArray objectAtIndex:1];
            cgResult = [[cgTemp componentsSeparatedByString:@","] objectAtIndex:0];
            cgResult = [cgResult substringFromIndex:1];
            if([cgResult isEqualToString:@"3"]){
                cgResult = @"胜";
            }else if([cgResult isEqualToString:@"1"]){
                cgResult = @"平";
            }else if([cgResult isEqualToString:@"0"]){
                cgResult = @"负";
            }
        }
    }
    return cgResult;
}

+(NSString *)dealJCLQSFCWithSfc:(NSString *)sfc;
{
    NSString *strSfc;
    if ([sfc isEqualToString:@"01"]) {
        strSfc = @"主胜1-5";
    } else if ([sfc isEqualToString:@"02"]) {
        strSfc = @"主胜6-10";
    } else if ([sfc isEqualToString:@"03"]) {
        strSfc = @"主胜11-15";
    } else if ([sfc isEqualToString:@"04"]) {
        strSfc = @"主胜16-20";
    } else if ([sfc isEqualToString:@"05"]) {
        strSfc = @"主胜21-25";
    } else if ([sfc isEqualToString:@"06"]) {
        strSfc = @"主胜26+";
    } else if ([sfc isEqualToString:@"11"]) {
        strSfc = @"客胜1-5";
    } else if ([sfc isEqualToString:@"12"]) {
        strSfc = @"客胜6-10";
    } else if ([sfc isEqualToString:@"13"]) {
        strSfc = @"客胜11-15";
    } else if ([sfc isEqualToString:@"14"]) {
        strSfc = @"客胜16-20";
    } else if ([sfc isEqualToString:@"15"]) {
        strSfc = @"客胜21-25";
    } else if ([sfc isEqualToString:@"16"]) {
        strSfc = @"客胜26+";
    }
    return strSfc;
}

+(NSMutableDictionary *)updateBuyLotteryListWithLotteryId:(NSInteger)lotteryId
{
    NSString *buyLotteryList = [NSString stringWithFormat:@"%@/buyLotteryList.dat", [JddCommonFunction thisDocumentPath]];
    NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithContentsOfFile:buyLotteryList];
    NSNumber *defaultBtn1 = [NSNumber numberWithInteger:LOTTERY_TYPE_ID_SHUANGSEQIU];
    NSNumber *defaultBtn2 = [NSNumber numberWithInteger:LOTTERY_TYPE_ID_DALETOU];
    NSNumber *defaultBtn3 = [NSNumber numberWithInteger:LOTTERY_TYPE_ID_11S5];
    NSNumber *defaultBtn4 = [NSNumber numberWithInteger:LOTTERY_TYPE_ID_FOOTBALL];

    if (![[NSFileManager defaultManager] fileExistsAtPath:buyLotteryList isDirectory:NO])
        {
        dictionary = [NSMutableDictionary dictionary];
        [dictionary setObject:defaultBtn1 forKey:@"btn1"];
        [dictionary setObject:defaultBtn2 forKey:@"btn2"];
        [dictionary setObject:defaultBtn3 forKey:@"btn3"];
        [dictionary setObject:defaultBtn4 forKey:@"btn4"];
        [dictionary setObject:[NSNumber numberWithBool:YES] forKey:@"isNew"];
        [dictionary writeToFile:buyLotteryList atomically:YES];
        }
    if (lotteryId != 0) {
        NSNumber *l1 = [dictionary objectForKey:@"btn1"];
        NSNumber *l2 = [dictionary objectForKey:@"btn2"];
        NSNumber *l3 = [dictionary objectForKey:@"btn3"];
        NSNumber *l4 = [dictionary objectForKey:@"btn4"];
        
        NSMutableArray *arr = [NSMutableArray arrayWithObjects:l1, l2, l3, l4, nil];
        BOOL isRemove = NO;
        for(NSUInteger i = 0; i < arr.count; i ++)
            {
            if ([[arr objectAtIndex:i] intValue] == lotteryId) {
                [arr removeObjectAtIndex:i];
                isRemove = YES;
                break;
                }
            }
        [arr insertObject:[NSNumber numberWithInteger:lotteryId] atIndex:0];
        if (!isRemove) {
            [arr removeLastObject];
        }
        l1 = [arr objectAtIndex:0];
        l2 = [arr objectAtIndex:1];
        l3 = [arr objectAtIndex:2];
        l4 = [arr objectAtIndex:3];
       
        [dictionary setObject:l1 forKey:@"btn1"];
        [dictionary setObject:l2 forKey:@"btn2"];
        [dictionary setObject:l3 forKey:@"btn3"];
        [dictionary setObject:l4 forKey:@"btn4"];
        [dictionary writeToFile:buyLotteryList atomically:YES];
    }
    else{
        if (![[dictionary objectForKey:@"isNew"] boolValue]) {
            [dictionary setObject:[NSNumber numberWithBool:YES] forKey:@"isNew"];
            NSNumber *l1 = defaultBtn1;
            NSNumber *l2 = defaultBtn2;
            NSNumber *l3 = defaultBtn3;
            NSNumber *l4 = defaultBtn4;
            [dictionary setObject:l1 forKey:@"btn1"];
            [dictionary setObject:l2 forKey:@"btn2"];
            [dictionary setObject:l3 forKey:@"btn3"];
            [dictionary setObject:l4 forKey:@"btn4"];
            [dictionary writeToFile:buyLotteryList atomically:YES];
        }
    }
    return dictionary;
}

+ (UIImage *)getImgByLevel:(NSString *)level
{
    NSString *imgName = [NSString stringWithFormat:@"jdd_level_markstar%@", level];
    UIImage *img = LOADIMAGE(imgName);
    return img;
}

+ (int )getTotetherBuyLottIdWithLotteryNameIndex:(int)index
{
    switch (index) {
        case 0:
            return 0;
            break;
        case 1:
            return LOTTERY_TYPE_ID_FOOTBALL;
            break;
        case 2:
            return LOTTERY_TYPE_ID_BASKETBALL;
            break;
        case 3:
            return LOTTERY_TYPE_ID_BD;
            break;
        case 4:
            return LOTTERY_TYPE_ID_SF;
            break;
        case 5:
            return LOTTERY_TYPE_ID_RX9;
            break;
        case 6:
            return LOTTERY_TYPE_ID_SHUANGSEQIU;
            break;
        case 7:
            return LOTTERY_TYPE_ID_DALETOU;
            break;
        case 8:
            return -1;
            break;
        default:
            return -1;
            break;
    }
}

+ (int )getSportLottIdWithLotteryNameIndex:(int)index
{
    int num = 0;
    switch (index) {
        case 0:
            num = LOTTERY_PLAY_METHOD_FOOTBALL;
            break;
        case 1:
            num = LOTTERY_PLAY_METHOD_FOOTBALL_SPF;
            break;
        case 2:
            num = LOTTERY_PLAY_METHOD_FOOTBALL_ZJQ;
            break;
        case 3:
            num = LOTTERY_PLAY_METHOD_FOOTBALL_BF;
            break;
        case 4:
            num = LOTTERY_PLAY_METHOD_FOOTBALL_BQC;
            break;
        case 5:
            num = LOTTERY_PLAY_METHOD_FOOTBALL_HH;
            break;
        default:
            break;
    }
    return num;
}

+ (int )getBaseketBallLottIdWithLotteryNameIndex:(int)index
{
    switch (index) {
        case 0:
            return LOTTERY_PLAY_METHOD_BASKETBALL_RFSF;
            break;
        case 1:
            return LOTTERY_PLAY_METHOD_BASKETBALL_SF;
            break;
        case 2:
            return LOTTERY_PLAY_METHOD_BASKETBALL_SFC;
            break;
        case 3:
            return LOTTERY_PLAY_METHOD_BASKETBALL_DXF;
            break;
        case 4:
            return LOTTERY_PLAY_METHOD_BASKETBALL_HH;
            break;
        default:
            break;
    }
}

+ (int )getBDLottIdWithLotteryNameIndex:(int)index
{
    switch (index) {
        case 0:
            return LOTTERY_PLAY_METHOD_BD;
            break;
        case 1:
            return LOTTERY_PLAY_METHOD_BD_ZJQ;
            break;
        case 2:
            return LOTTERY_PLAY_METHOD_BD_SXDS;
            break;
        case 3:
            return LOTTERY_PLAY_METHOD_BD_BF;
            break;
        case 4:
            return LOTTERY_PLAY_METHOD_BD_BQC;
            break;
        default:
            break;
    }
}

+(NSString *)getImgByLotteryId:(NSInteger )lotteryId
{
    NSString *name;
    switch (lotteryId) {
        case LOTTERY_TYPE_ID_SHUANGSEQIU:
            name = @"jdd_buy_main_ssq";
            break;
        case LOTTERY_TYPE_ID_DALETOU:
            name = @"jdd_buy_main_dlt";
            break;
        case LOTTERY_TYPE_ID_11S5:
            name = @"jdd_buy_main_11five";
            break;
        case LOTTERY_TYPE_ID_FOOTBALL:
            name = @"jdd_buy_main_jc";
            break;
        case LOTTERY_TYPE_ID_BD:
            name = @"jdd_buy_main_bd";
            break;
        case LOTTERY_TYPE_ID_BASKETBALL:
            name = @"jdd_buy_main_jclq";
            break;
        case LOTTERY_TYPE_ID_SF:
            name = @"jdd_buy_main_sfc";
            break;
        case LOTTERY_TYPE_ID_RX9:
            name = @"jdd_buy_main_rx9";
            break;
        case LOTTERY_TYPE_ID_FC3D:
            name = @"jdd_buy_main_3d";
            break;
        case LOTTERY_TYPE_ID_7LC:
            name = @"jdd_buy_main_n7l";
            break;
        case LOTTERY_TYPE_ID_PL3:
            name = @"jdd_buy_main_p3";
            break;
        case LOTTERY_TYPE_ID_PL5:
            name = @"jdd_buy_main_p5";
            break;
        case LOTTERY_TYPE_ID_7XC:
            name = @"jdd_buy_main_n7x";
            break;
        case LOTTERY_TYPE_ID_11YDJ:
            name = @"jdd_buy_main_11ydj";
            break;
        case LOTTERY_TYPE_ID_CQSS:
            name = @"jdd_buy_main_ssc";
            break;
    }
    return name;
}


+(NSString *)getNameByLotteryId:(NSInteger )lotteryId
{
    NSString *name;
    switch (lotteryId) {
        case LOTTERY_TYPE_ID_SHUANGSEQIU:
            name = @"双色球";
            break;
        case LOTTERY_TYPE_ID_DALETOU:
            name = @"大乐透";
            break;
        case LOTTERY_TYPE_ID_11S5:
            name = @"11选5";
            break;
        case LOTTERY_TYPE_ID_FOOTBALL:
            name = @"竞彩足球";
            break;
        case LOTTERY_TYPE_ID_BD:
            name = @"北京单场";
            break;
        case LOTTERY_TYPE_ID_BASKETBALL:
            name = @"竞彩篮球";
            break;
        case LOTTERY_TYPE_ID_SF:
            name = @"胜负彩";
            break;
        case LOTTERY_TYPE_ID_RX9:
            name = @"任选九";
            break;
        case LOTTERY_TYPE_ID_FC3D:
            name = @"福彩3D";
            break;
        case LOTTERY_TYPE_ID_7LC:
            name = @"七乐彩";
            break;
        case LOTTERY_TYPE_ID_PL3:
            name = @"排列3";
            break;
        case LOTTERY_TYPE_ID_PL5:
            name = @"排列5";
            break;
        case LOTTERY_TYPE_ID_7XC:
            name = @"七星彩";
            break;
        case LOTTERY_TYPE_ID_11YDJ:
            name = @"11运夺金";
            break;
        case LOTTERY_TYPE_ID_CQSS:
            name = @"重庆时时彩";
            break;
    }
    return name;
}

+(NSInteger)getLotteryIdByName:(NSString *)Name
{
    NSInteger lotteryId = LOTTERY_TYPE_ID_SHUANGSEQIU;
    if ([Name isEqualToString:@"双色球"]) {
        lotteryId = LOTTERY_TYPE_ID_SHUANGSEQIU;
    }else if ([Name isEqualToString:@"大乐透"]) {
        lotteryId = LOTTERY_TYPE_ID_DALETOU;
    }else if ([Name isEqualToString:@"11选5"]) {
        lotteryId = LOTTERY_TYPE_ID_11S5;
    }else if ([Name isEqualToString:@"竞彩足球"]) {
        lotteryId = LOTTERY_TYPE_ID_FOOTBALL;
    }else if ([Name isEqualToString:@"足彩单场"]) {
        lotteryId = LOTTERY_TYPE_ID_BD;
    }else if ([Name isEqualToString:@"竞彩篮球"]) {
        lotteryId = LOTTERY_TYPE_ID_BASKETBALL;
    }else if ([Name isEqualToString:@"胜负彩"]) {
        lotteryId = LOTTERY_TYPE_ID_SF;
    }else if ([Name isEqualToString:@"任选九"]) {
        lotteryId = LOTTERY_TYPE_ID_RX9;
    }else if ([Name isEqualToString:@"福彩3D"]) {
        lotteryId = LOTTERY_TYPE_ID_FC3D;
    }else if ([Name isEqualToString:@"七乐彩"]) {
        lotteryId = LOTTERY_TYPE_ID_7LC;
    }else if ([Name isEqualToString:@"排列3"]) {
        lotteryId = LOTTERY_TYPE_ID_PL3;
    }else if ([Name isEqualToString:@"排列5"]) {
        lotteryId = LOTTERY_TYPE_ID_PL5;
    }else if ([Name isEqualToString:@"七星彩"]) {
        lotteryId = LOTTERY_TYPE_ID_7XC;
    }else if ([Name isEqualToString:@"11运夺金"]) {
        lotteryId = LOTTERY_TYPE_ID_11YDJ;
    }else if ([Name isEqualToString:@"重庆时时彩"]) {
        lotteryId = LOTTERY_TYPE_ID_CQSS;
    }
    return lotteryId;
}

+(NSString *)getScoreDateTimeFormString:(NSString *)date
{
    date = [date substringFromIndex:3];
    date = [date stringByReplacingOccurrencesOfString:@" " withString:@"日"];
    return date;
}

+ (BOOL)isAliPayUser
{
    if([JddUserProfile sharedInstance].password.length >5)
        {
            return NO;
        }else{
            return YES;
        }
}


+(void)setViewBackgroundWithImageName:(NSString *)imageName AndView:(UIView *)view
{
    view.backgroundColor =[UIColor colorWithPatternImage:LOADIMAGE(imageName)];
}

+(NSString *)getCgWithFangAnCg:(NSString *)cg AndPlayTypeName:(NSString *)playTypeName
{
    if (([playTypeName isEqualToString:@"让球胜平负"]) || ([playTypeName isEqualToString:@"胜平负"]) || ([playTypeName isEqualToString:@"半全场"])) {
    if(!([cg isEqualToString:@""]) && !([cg isEqualToString:@"-"])){
        cg = [cg stringByReplacingOccurrencesOfString:@"3" withString:@"胜"];
        cg = [cg stringByReplacingOccurrencesOfString:@"1" withString:@"平"];
        cg = [cg stringByReplacingOccurrencesOfString:@"0" withString:@"负"];
        }
        //北单
    }else if([playTypeName isEqualToString:@"上下盘"] || [playTypeName isEqualToString:@"上下单双"]){
        if(!([cg isEqualToString:@""]) && !([cg isEqualToString:@"-"])){
            cg = [cg stringByReplacingOccurrencesOfString:@"3" withString:@"上单"];
            cg = [cg stringByReplacingOccurrencesOfString:@"2" withString:@"上双"];
            cg = [cg stringByReplacingOccurrencesOfString:@"1" withString:@"下单"];
            cg = [cg stringByReplacingOccurrencesOfString:@"0" withString:@"下双"];
        }
    } //北单
    else if([playTypeName isEqualToString:@"猜比分"]){
        if(!([cg isEqualToString:@""]) && !([cg isEqualToString:@"-"])){
            cg = [cg stringByReplacingOccurrencesOfString:@"90" withString:@"胜其他"];
            cg = [cg stringByReplacingOccurrencesOfString:@"99" withString:@"平其他"];
            cg = [cg stringByReplacingOccurrencesOfString:@"09" withString:@"负其他"];
            NSInteger cgLength = cg.length;
            if (cgLength == 2) {
                cg = [NSString stringWithFormat:@"%@:%@", [cg substringToIndex:1], [cg substringFromIndex:1]];
            }
        }
    }
    return cg;
}

+(NSInteger)getNumberByStrDXDS:(NSString *)str
{
    NSArray *arr = [NSArray arrayWithObjects:@"大", @"小", @"单", @"双", nil];
    return [arr indexOfObject:str];
}

+(NSString *)getStrDXDSByNumber:(NSInteger)number
{
    NSArray *arr = [NSArray arrayWithObjects:@"大", @"小", @"单", @"双", nil];
    return [arr objectAtIndex:number];
}

+(int)getCountNumberWithNumberArray:(NSMutableArray *)numberArray AndPlayMethodTemp:(NSMutableArray *)playMethodTemp
{
    int count = 0;
    for (NSString* platMethod in playMethodTemp) {
        if ([platMethod isEqualToString:@"单关"]) {
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i ];
                int num1 = [ssqNumber.teamArray count];
                count += num1;
            }
        }
        else if ([platMethod isEqualToString:@"2串1"]) {
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i ];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    count += num1*num2;
                }
            }
        } else if ([platMethod isEqualToString:@"3串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i ];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        count += num1*num2*num3;
                    }
                }
            }
        } else if ([platMethod isEqualToString:@"4串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i ];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            count += num1*num2*num3*num4;
                        }
                    }
                }
            }
        } else if ([platMethod isEqualToString:@"5串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i ];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                count += num1*num2*num3*num4*num5;
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"6串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i ];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    count += num1*num2*num3*num4*num5*num6;
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"7串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i ];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        count += num1*num2*num3*num4*num5*num6*num7;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"8串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        for (int dan6 = dan5+1; dan6 < [numberArray count]; ++dan6) {
                                            JddSportNumber *ssqNumber8 = [numberArray objectAtIndex:dan6];
                                            int num8 = [ssqNumber8.teamArray count];
                                            count += num1*num2*num3*num4*num5*num6*num7*num8;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"9串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        for (int dan6 = dan5+1; dan6 < [numberArray count]; ++dan6) {
                                            JddSportNumber *ssqNumber8 = [numberArray objectAtIndex:dan6];
                                            int num8 = [ssqNumber8.teamArray count];
                                            for (int dan7 = dan6+1; dan7 < [numberArray count]; ++dan7) {
                                                JddSportNumber *ssqNumber9 = [numberArray objectAtIndex:dan7];
                                                int num9 = [ssqNumber9.teamArray count];
                                                count += num1*num2*num3*num4*num5*num6*num7*num8*num9;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"10串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        for (int dan6 = dan5+1; dan6 < [numberArray count]; ++dan6) {
                                            JddSportNumber *ssqNumber8 = [numberArray objectAtIndex:dan6];
                                            int num8 = [ssqNumber8.teamArray count];
                                            for (int dan7 = dan6+1; dan7 < [numberArray count]; ++dan7) {
                                                JddSportNumber *ssqNumber9 = [numberArray objectAtIndex:dan7];
                                                int num9 = [ssqNumber9.teamArray count];
                                                for (int dan8 = dan7+1; dan8 < [numberArray count]; ++dan8) {
                                                    JddSportNumber *ssqNumber10 = [numberArray objectAtIndex:dan8];
                                                    int num10 = [ssqNumber10.teamArray count];
                                                    count += num1*num2*num3*num4*num5*num6*num7*num8*num9*num10;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"11串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        for (int dan6 = dan5+1; dan6 < [numberArray count]; ++dan6) {
                                            JddSportNumber *ssqNumber8 = [numberArray objectAtIndex:dan6];
                                            int num8 = [ssqNumber8.teamArray count];
                                            for (int dan7 = dan6+1; dan7 < [numberArray count]; ++dan7) {
                                                JddSportNumber *ssqNumber9 = [numberArray objectAtIndex:dan7];
                                                int num9 = [ssqNumber9.teamArray count];
                                                for (int dan8 = dan7+1; dan8 < [numberArray count]; ++dan8) {
                                                    JddSportNumber *ssqNumber10 = [numberArray objectAtIndex:dan8];
                                                    int num10 = [ssqNumber10.teamArray count];
                                                    for (int dan9 = dan8+1; dan9 < [numberArray count]; ++dan9) {
                                                        JddSportNumber *ssqNumber11 = [numberArray objectAtIndex:dan9];
                                                        int num11 = [ssqNumber11.teamArray count];
                                                        count += num1*num2*num3*num4*num5*num6*num7*num8*num9*num10*num11;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"12串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        for (int dan6 = dan5+1; dan6 < [numberArray count]; ++dan6) {
                                            JddSportNumber *ssqNumber8 = [numberArray objectAtIndex:dan6];
                                            int num8 = [ssqNumber8.teamArray count];
                                            for (int dan7 = dan6+1; dan7 < [numberArray count]; ++dan7) {
                                                JddSportNumber *ssqNumber9 = [numberArray objectAtIndex:dan7];
                                                int num9 = [ssqNumber9.teamArray count];
                                                for (int dan8 = dan7+1; dan8 < [numberArray count]; ++dan8) {
                                                    JddSportNumber *ssqNumber10 = [numberArray objectAtIndex:dan8];
                                                    int num10 = [ssqNumber10.teamArray count];
                                                    for (int dan9 = dan8+1; dan9 < [numberArray count]; ++dan9) {
                                                        JddSportNumber *ssqNumber11 = [numberArray objectAtIndex:dan9];
                                                        int num11 = [ssqNumber11.teamArray count];
                                                        for (int dan10 = dan9+1; dan10 < [numberArray count]; ++dan10) {
                                                            JddSportNumber *ssqNumber12 = [numberArray objectAtIndex:dan10];
                                                            int num12 = [ssqNumber12.teamArray count];
                                                            count += num1*num2*num3*num4*num5*num6*num7*num8*num9*num10*num11*num12;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"13串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        for (int dan6 = dan5+1; dan6 < [numberArray count]; ++dan6) {
                                            JddSportNumber *ssqNumber8 = [numberArray objectAtIndex:dan6];
                                            int num8 = [ssqNumber8.teamArray count];
                                            for (int dan7 = dan6+1; dan7 < [numberArray count]; ++dan7) {
                                                JddSportNumber *ssqNumber9 = [numberArray objectAtIndex:dan7];
                                                int num9 = [ssqNumber9.teamArray count];
                                                for (int dan8 = dan7+1; dan8 < [numberArray count]; ++dan8) {
                                                    JddSportNumber *ssqNumber10 = [numberArray objectAtIndex:dan8];
                                                    int num10 = [ssqNumber10.teamArray count];
                                                    for (int dan9 = dan8+1; dan9 < [numberArray count]; ++dan9) {
                                                        JddSportNumber *ssqNumber11 = [numberArray objectAtIndex:dan9];
                                                        int num11 = [ssqNumber11.teamArray count];
                                                        for (int dan10 = dan9+1; dan10 < [numberArray count]; ++dan10) {
                                                            JddSportNumber *ssqNumber12 = [numberArray objectAtIndex:dan10];
                                                            int num12 = [ssqNumber12.teamArray count];
                                                            for (int dan11 = dan10+1; dan11 < [numberArray count]; ++dan11) {
                                                                JddSportNumber *ssqNumber13 = [numberArray objectAtIndex:dan11];
                                                                int num13 = [ssqNumber13.teamArray count];
                                                                count += num1*num2*num3*num4*num5*num6*num7*num8*num9*num10*num11*num12*num13;
                                                            }                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"14串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        for (int dan6 = dan5+1; dan6 < [numberArray count]; ++dan6) {
                                            JddSportNumber *ssqNumber8 = [numberArray objectAtIndex:dan6];
                                            int num8 = [ssqNumber8.teamArray count];
                                            for (int dan7 = dan6+1; dan7 < [numberArray count]; ++dan7) {
                                                JddSportNumber *ssqNumber9 = [numberArray objectAtIndex:dan7];
                                                int num9 = [ssqNumber9.teamArray count];
                                                for (int dan8 = dan7+1; dan8 < [numberArray count]; ++dan8) {
                                                    JddSportNumber *ssqNumber10 = [numberArray objectAtIndex:dan8];
                                                    int num10 = [ssqNumber10.teamArray count];
                                                    for (int dan9 = dan8+1; dan9 < [numberArray count]; ++dan9) {
                                                        JddSportNumber *ssqNumber11 = [numberArray objectAtIndex:dan9];
                                                        int num11 = [ssqNumber11.teamArray count];
                                                        for (int dan10 = dan9+1; dan10 < [numberArray count]; ++dan10) {
                                                            JddSportNumber *ssqNumber12 = [numberArray objectAtIndex:dan10];
                                                            int num12 = [ssqNumber12.teamArray count];
                                                            for (int dan11 = dan10+1; dan11 < [numberArray count]; ++dan11) {
                                                                JddSportNumber *ssqNumber13 = [numberArray objectAtIndex:dan11];
                                                                int num13 = [ssqNumber13.teamArray count];
                                                                for (int dan12 = dan11+1; dan12 < [numberArray count]; ++dan12) {
                                                                    JddSportNumber *ssqNumber14 = [numberArray objectAtIndex:dan12];
                                                                    int num14 = [ssqNumber14.teamArray count];
                                                                    count += num1*num2*num3*num4*num5*num6*num7*num8*num9*num10*num11*num12*num13*num14;
                                                                }                                                              }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }else if ([platMethod isEqualToString:@"15串1"]){
            for (int i = 0; i<[numberArray count]; ++i) {
                JddSportNumber *ssqNumber = [numberArray objectAtIndex:i];
                int num1 = [ssqNumber.teamArray count];
                for (int j = i+1; j<[numberArray count]; ++j) {
                    JddSportNumber *ssqNumber2 = [numberArray objectAtIndex:j];
                    int num2 = [ssqNumber2.teamArray count];
                    for (int dan1 = j+1; dan1 < [numberArray count]; ++dan1) {
                        JddSportNumber *ssqNumber3 = [numberArray objectAtIndex:dan1];
                        int num3 = [ssqNumber3.teamArray count];
                        for (int dan2 = dan1+1; dan2 < [numberArray count]; ++dan2) {
                            JddSportNumber *ssqNumber4 = [numberArray objectAtIndex:dan2];
                            int num4 = [ssqNumber4.teamArray count];
                            for (int dan3 = dan2+1; dan3 < [numberArray count]; ++dan3) {
                                JddSportNumber *ssqNumber5 = [numberArray objectAtIndex:dan3];
                                int num5 = [ssqNumber5.teamArray count];
                                for (int dan4 = dan3+1; dan4 < [numberArray count]; ++dan4) {
                                    JddSportNumber *ssqNumber6 = [numberArray objectAtIndex:dan4];
                                    int num6 = [ssqNumber6.teamArray count];
                                    for (int dan5 = dan4+1; dan5 < [numberArray count]; ++dan5) {
                                        JddSportNumber *ssqNumber7 = [numberArray objectAtIndex:dan5];
                                        int num7 = [ssqNumber7.teamArray count];
                                        for (int dan6 = dan5+1; dan6 < [numberArray count]; ++dan6) {
                                            JddSportNumber *ssqNumber8 = [numberArray objectAtIndex:dan6];
                                            int num8 = [ssqNumber8.teamArray count];
                                            for (int dan7 = dan6+1; dan7 < [numberArray count]; ++dan7) {
                                                JddSportNumber *ssqNumber9 = [numberArray objectAtIndex:dan7];
                                                int num9 = [ssqNumber9.teamArray count];
                                                for (int dan8 = dan7+1; dan8 < [numberArray count]; ++dan8) {
                                                    JddSportNumber *ssqNumber10 = [numberArray objectAtIndex:dan8];
                                                    int num10 = [ssqNumber10.teamArray count];
                                                    for (int dan9 = dan8+1; dan9 < [numberArray count]; ++dan9) {
                                                        JddSportNumber *ssqNumber11 = [numberArray objectAtIndex:dan9];
                                                        int num11 = [ssqNumber11.teamArray count];
                                                        for (int dan10 = dan9+1; dan10 < [numberArray count]; ++dan10) {
                                                            JddSportNumber *ssqNumber12 = [numberArray objectAtIndex:dan10];
                                                            int num12 = [ssqNumber12.teamArray count];
                                                            for (int dan11 = dan10+1; dan11 < [numberArray count]; ++dan11) {
                                                                JddSportNumber *ssqNumber13 = [numberArray objectAtIndex:dan11];
                                                                int num13 = [ssqNumber13.teamArray count];
                                                                for (int dan12 = dan11+1; dan12 < [numberArray count]; ++dan12) {
                                                                    JddSportNumber *ssqNumber14 = [numberArray objectAtIndex:dan12];
                                                                    int num14 = [ssqNumber14.teamArray count];
                                                                    for (int dan13 = dan12+1; dan13 < [numberArray count]; ++dan13) {
                                                                        JddSportNumber *ssqNumber15 = [numberArray objectAtIndex:dan13];
                                                                        int num15 = [ssqNumber15.teamArray count];
                                                                        count += num1*num2*num3*num4*num5*num6*num7*num8*num9*num10*num11*num12*num13*num14*num15;
                                                                    }                                                                  }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return count;
}
+(void)clearViewControllers
{
    [[JddPickNum11s5ListViewController sharedInstance] destoryView];
    [[JddPickNum11s5ViewController sharedInstance] destoryView];
    [[JddPickNumDaLeTouListViewController sharedInstance] destoryView];
    [[JddPickNumDaLeTouViewController sharedInstance] destoryView];
    [[JddPickNumShuangSeQiuListViewController sharedInstance] destoryView];
    [[JddPickNumShuangSeQiuViewController sharedInstance] destoryView];
    [[JddPickNumSportListViewController sharedInstance] destoryView];
    
    [[JddPickNumFC3DViewController sharedInstance] destoryView];
    [[JddPickNumFC3DListViewController sharedInstance] destoryView];
    [[JddPickNum7lcViewController sharedInstance] destoryView];
    [[JddPickNum7lcListViewController sharedInstance] destoryView];
    [[JddPickNum7xcViewController sharedInstance] destoryView];
    [[JddPickNum7xcListViewController sharedInstance] destoryView];
    [[JddPickNumBDListViewController sharedInstance] destoryView];
    [[JddPickNumBasketBallListViewController sharedInstance] destoryView];
    [[JddPickNumSFCViewController sharedInstance] destoryView];
    [[JddPickNumSFCListViewController sharedInstance] destoryView];
    [[JddPickNumRX9ViewController sharedInstance] destoryView];
    [[JddPickNumRX9ListViewController sharedInstance] destoryView];
    [[JddPickNumP3ViewController sharedInstance] destoryView];
    [[JddPickNumP3ListViewController sharedInstance] destoryView];
    [[JddPickNumP5ViewController sharedInstance] destoryView];
    [[JddPickNumP5ListViewController sharedInstance] destoryView];
    [[JddPickNum11YDJViewController sharedInstance] destoryView];
    [[JddPickNum11YDJListViewController sharedInstance] destoryView];
    [[JddPickNumCQSSListViewController sharedInstance] destoryView];
}


/* 调整图片大小 */
+ (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size
{
    UIGraphicsBeginImageContext(size);
    [img drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return scaledImage;
}

/* url参数分析 */
+ (NSDictionary*)dictionaryFromQuery:(NSString*)query usingEncoding:(NSStringEncoding)encoding
{
    NSCharacterSet* delimiterSet = [NSCharacterSet characterSetWithCharactersInString:@"&;"];
    NSMutableDictionary* pairs = [NSMutableDictionary dictionary];
    NSScanner* scanner = [[NSScanner alloc] initWithString:query];
    while (![scanner isAtEnd])
    {
        NSString* pairString = nil;
        [scanner scanUpToCharactersFromSet:delimiterSet intoString:&pairString];
        [scanner scanCharactersFromSet:delimiterSet intoString:NULL];
        NSArray* kvPair = [pairString componentsSeparatedByString:@"="];
        if (kvPair.count == 2) {
            NSString* key = [[kvPair objectAtIndex:0]
                             stringByReplacingPercentEscapesUsingEncoding:encoding];
            NSString* value = [[kvPair objectAtIndex:1]
                               stringByReplacingPercentEscapesUsingEncoding:encoding];
            [pairs setObject:value forKey:key];
        }
    }
    
    return [NSDictionary dictionaryWithDictionary:pairs];
}

//! 放大缩小动画 以示突出
+ (void) animationViewWithZoomOutIn:(UIView *)aView delaySecond:(float)delay
{
    [UIView animateWithDuration:0.3 delay:delay options:UIViewAnimationOptionCurveEaseInOut animations:^{
        
        aView.transform = CGAffineTransformMakeScale(1.1, 1.1);
        
    } completion:^(BOOL finished) {
        
        [UIView animateWithDuration:0.5 animations:^{
            aView.transform = CGAffineTransformMakeScale(1.0, 1.0);
        } completion:^(BOOL finished) {
            
        }];
        
    }];
}


//保存图片
+(BOOL)saveImageToPath:(UIImage *)image withFileName:(NSString *)imageName withPath:(NSString *)path withData:(NSMutableDictionary*)infoDic
{
    NSString *imagePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",imageName]];
    
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if (![fileManager fileExistsAtPath:path]) {
		if (![fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil])
        {}
    }
    
    NSData *data = UIImagePNGRepresentation(image);
    BOOL result = [data writeToFile:imagePath atomically:YES];
	if (result) {
		NSLog(@"存储图片成功");
	}
    return YES;
}


+ (BOOL)savePlistInfo:(NSArray *)arr{
    BOOL ret = NO;
    //获取plist文件路径
    //获取应用程序沙盒的Documents目录
    NSString *plistPath = [[[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"lotteryhall"] stringByAppendingPathComponent:@"banner"] stringByAppendingPathComponent:@"bannerPlist"];
    plistPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
    NSFileManager *fileManager = [NSFileManager defaultManager];
    
    //得到完整的文件名
    NSString *filename=[plistPath stringByAppendingPathComponent:@"bannerPic.plist"];
    if (![fileManager fileExistsAtPath:filename]) {
        [fileManager createFileAtPath:filename contents:nil attributes:nil];
    }
    NSMutableDictionary *banDic = [[NSMutableDictionary alloc] init];
    for (NSInteger i=0; i<arr.count; i++) {
        NSDictionary *infoDic = [arr objectAtIndex:i];
        [banDic setObject:infoDic forKey:[NSString stringWithFormat:@"banner%d",i]];
    }
    if ([banDic writeToFile:filename atomically:YES]) {
        //NSLog(@"存储Plist成功");
    }
    return ret;
}

+(NSString *)getBannerFileName:(NSString *)imageName withPath:(NSString *)path{
    NSString *imagePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",imageName]];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if ([fileManager fileExistsAtPath:imagePath]) {
		return [NSString stringWithFormat:@"%@",imagePath];
    }
    return nil;
}

+(NSMutableDictionary *)getBannerPicUrlPlist{
    //获取应用程序沙盒的Documents目录
    NSString *bannerPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
    //得到完整的文件名
    NSString *filename=[bannerPath stringByAppendingPathComponent:@"bannerPic.plist"];
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithContentsOfFile:filename];
    return dic;
}



@end

@implementation NSString(md5)

-(NSString*)myMd5{
	const char *cStr = [self UTF8String];
	unsigned char result[16];
	CC_MD5(cStr, strlen(cStr), result);
	return [NSString stringWithFormat:
			@"%02x%02x%02x%02x%02x%02x%02x%02x",
			result[4], result[5], result[6], result[7],
			result[8], result[9], result[10], result[11]];
}	

-(NSString*)my32Md5{
	const char *cStr = [self UTF8String];
	unsigned char result[32];
	CC_MD5(cStr, strlen(cStr), result);
	return [NSString stringWithFormat:
			@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
			result[0], result[1], result[2], result[3], 
			result[4], result[5], result[6], result[7],
			result[8], result[9], result[10], result[11],
			result[12], result[13], result[14], result[15]];
}	

@end

@implementation NSMutableString(md5)

-(NSString*)myMd5{
	const char *cStr = [self UTF8String];
	unsigned char result[16];
	CC_MD5(cStr, strlen(cStr), result);
	return [NSString stringWithFormat:
			@"%02x%02x%02x%02x%02x%02x%02x%02x",
			result[4], result[5], result[6], result[7],
			result[8], result[9], result[10], result[11]];
}

-(NSString*)my32Md5{
	const char *cStr = [self UTF8String];
	unsigned char result[32];
	CC_MD5(cStr, strlen(cStr), result);
	return [NSString stringWithFormat:
			@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
			result[0], result[1], result[2], result[3], 
			result[4], result[5], result[6], result[7],
			result[8], result[9], result[10], result[11],
			result[12], result[13], result[14], result[15]];
}

@end
